<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  

  
  <title>JavaScript基础知识点--event对象常用属性和方法 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="event常用属性和方法常用属性和方法表   属性或方法 说明    type 事件的类型   srcElement/target 事件源，就是发生事件的元素   cancelBubble 布尔属性。设为 true 的时候，将停止事件进一步起泡到包容层次的元素（Ele.cancelBubble = true;相当于Ele.stopPropagation();）   returnValue 布尔属">
<meta name="keywords" content="JavaScript">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript基础知识点--event对象常用属性和方法">
<meta property="og:url" content="http://yoursite.com/2019/09/01/JavaScript基础知识点--event对象常用属性和方法/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="event常用属性和方法常用属性和方法表   属性或方法 说明    type 事件的类型   srcElement/target 事件源，就是发生事件的元素   cancelBubble 布尔属性。设为 true 的时候，将停止事件进一步起泡到包容层次的元素（Ele.cancelBubble = true;相当于Ele.stopPropagation();）   returnValue 布尔属">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2019-09-04T13:23:04.944Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="JavaScript基础知识点--event对象常用属性和方法">
<meta name="twitter:description" content="event常用属性和方法常用属性和方法表   属性或方法 说明    type 事件的类型   srcElement/target 事件源，就是发生事件的元素   cancelBubble 布尔属性。设为 true 的时候，将停止事件进一步起泡到包容层次的元素（Ele.cancelBubble = true;相当于Ele.stopPropagation();）   returnValue 布尔属">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-JavaScript基础知识点--event对象常用属性和方法" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/09/01/JavaScript基础知识点--event对象常用属性和方法/" class="article-date">
  <time datetime="2019-09-01T07:11:45.000Z" itemprop="datePublished">2019-09-01</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/JavaScript/">JavaScript</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      JavaScript基础知识点--event对象常用属性和方法
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h1 id="event常用属性和方法"><a href="#event常用属性和方法" class="headerlink" title="event常用属性和方法"></a>event常用属性和方法</h1><h2 id="常用属性和方法表"><a href="#常用属性和方法表" class="headerlink" title="常用属性和方法表"></a>常用属性和方法表</h2><table>
<thead>
<tr>
<th>属性或方法</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>type</td>
<td>事件的类型</td>
</tr>
<tr>
<td>srcElement/target</td>
<td>事件源，就是发生事件的元素</td>
</tr>
<tr>
<td>cancelBubble</td>
<td>布尔属性。设为 true 的时候，将停止事件进一步起泡到包容层次的元素（Ele.cancelBubble = true;相当于Ele.stopPropagation();）</td>
</tr>
<tr>
<td>returnValue</td>
<td>布尔属性。设置为 false 的时候可以阻止浏览器执行默认的事件动作（Ele.returnValue = false;相当于Ele.preventDefault();）</td>
</tr>
<tr>
<td>clientX/clientY</td>
<td>事件发生的时候，鼠标相对于浏览器窗口可视文档区域的左上角的位置</td>
</tr>
<tr>
<td>offsetX/offsetY</td>
<td>事件发生的时候，鼠标相对于事件源元素左上角的位置</td>
</tr>
<tr>
<td>initEvent()</td>
<td>初始化新创建的Event对象的属性</td>
</tr>
</tbody></table>
<p>说明：event 对象的所有属性列表可以在浏览器控制台中输出查看</p>
<h2 id="event-type"><a href="#event-type" class="headerlink" title="event.type"></a>event.type</h2><p>返回当前触发事件的类型</p>
<h2 id="event-target"><a href="#event-target" class="headerlink" title="event.target"></a>event.target</h2><p>事件源。返回触发事件的元素</p>
<h2 id="event-currentTarget"><a href="#event-currentTarget" class="headerlink" title="event.currentTarget"></a>event.currentTarget</h2><p>返回事件绑定的元素</p>
<h2 id="event-preventDefault"><a href="#event-preventDefault" class="headerlink" title="event.preventDefault()"></a>event.preventDefault()</h2><p>阻止浏览器执行默认行为</p>
<h2 id="event-stopPropagation"><a href="#event-stopPropagation" class="headerlink" title="event.stopPropagation()"></a>event.stopPropagation()</h2><p>阻止事件的捕获或冒泡</p>
<h2 id="event-clientY"><a href="#event-clientY" class="headerlink" title="event.clientY"></a>event.clientY</h2><p>clientY 事件属性返回当事件被触发时鼠标指针距浏览器顶部底边的距离，不包括滚动条滚动的部分</p>
<h2 id="event-pageY"><a href="#event-pageY" class="headerlink" title="event.pageY"></a>event.pageY</h2><p>pageY 事件属性返回当事件被触发时鼠标指针距浏览器顶部底边的距离，包括滚动条滚动的部分</p>
<h2 id="event-screenY"><a href="#event-screenY" class="headerlink" title="event.screenY"></a>event.screenY</h2><p>屏幕顶端到鼠标位置</p>
<h2 id="event-button"><a href="#event-button" class="headerlink" title="event.button"></a>event.button</h2><table>
<thead>
<tr>
<th>值</th>
<th>代表</th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>鼠标左键</td>
</tr>
<tr>
<td>1</td>
<td>鼠标中键</td>
</tr>
<tr>
<td>2</td>
<td>鼠标右键</td>
</tr>
</tbody></table>
<h2 id="touchcancel"><a href="#touchcancel" class="headerlink" title="touchcancel"></a>touchcancel</h2><p>当系统停止跟踪触摸时触发</p>
<h2 id="event-touches"><a href="#event-touches" class="headerlink" title="event.touches"></a>event.touches</h2><p>当前触摸屏幕的触摸点数组</p>
<h2 id="event-changedTouches"><a href="#event-changedTouches" class="headerlink" title="event.changedTouches"></a>event.changedTouches</h2><p>数组中只包含引起事件的触摸点信息</p>
<h2 id="event-targetTouches"><a href="#event-targetTouches" class="headerlink" title="event.targetTouches"></a>event.targetTouches</h2><p>只包含放在元素上的触摸信息</p>
<h2 id="IE事件独有"><a href="#IE事件独有" class="headerlink" title="IE事件独有"></a>IE事件独有</h2><h3 id="event-returnValue-false"><a href="#event-returnValue-false" class="headerlink" title="event.returnValue = false"></a>event.returnValue = false</h3><p>阻止默认行为。同 preventDefault</p>
<h3 id="event-cancleBubble-true"><a href="#event-cancleBubble-true" class="headerlink" title="event.cancleBubble = true"></a>event.cancleBubble = true</h3><p>取消事件冒泡。同 stopPropagation</p>
<h3 id="srcElement"><a href="#srcElement" class="headerlink" title="srcElement"></a>srcElement</h3><p>同 target</p>
<h3 id="event-button-1"><a href="#event-button-1" class="headerlink" title="event.button"></a>event.button</h3><table>
<thead>
<tr>
<th>值</th>
<th>代表</th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>没有按下按钮</td>
</tr>
<tr>
<td>1</td>
<td>按下主鼠标按钮</td>
</tr>
<tr>
<td>2</td>
<td>按下次鼠标按钮</td>
</tr>
<tr>
<td>3</td>
<td>同时按下主、次鼠标按钮</td>
</tr>
<tr>
<td>4</td>
<td>按钮中间鼠标按钮</td>
</tr>
</tbody></table>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2019/09/01/JavaScript基础知识点--event对象常用属性和方法/" data-id="ck4r400q1004ml0w0p6stamiy" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/">JavaScript</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2019/09/13/JavaScript进阶知识点-JS变量与作用域/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          JavaScript进阶知识点--JS变量与作用域
        
      </div>
    </a>
  
  
    <a href="/2019/08/31/JavaScript基础知识点-JS事件/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">JavaScript基础知识点--JS事件</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Ajax/">Ajax</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS/">CSS</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS3/">CSS3</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Dart/">Dart</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Flutter/">Flutter</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Git/">Git</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/HTML/">HTML</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/HTML5/">HTML5</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JSON/">JSON</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JavaScript/">JavaScript</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/QT/">QT</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/React/">React</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Sass/">Sass</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/TheKnowledgeOf/">TheKnowledgeOf</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/TypeScript/">TypeScript</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/bootstrap/">bootstrap</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/jQuery/">jQuery</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Ajax/">Ajax</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS/">CSS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS3/">CSS3</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Dart/">Dart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Flutter/">Flutter</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Git/">Git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTML/">HTML</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTML5/">HTML5</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JSON/">JSON</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/">Java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Javascript/">Javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/QT/">QT</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React/">React</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Sass/">Sass</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/TheKnowledgeOf/">TheKnowledgeOf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/TypeScript/">TypeScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/bootstrap/">bootstrap</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jQuery/">jQuery</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Ajax/" style="font-size: 12.22px;">Ajax</a> <a href="/tags/CSS/" style="font-size: 18.89px;">CSS</a> <a href="/tags/CSS3/" style="font-size: 17.78px;">CSS3</a> <a href="/tags/Dart/" style="font-size: 14.44px;">Dart</a> <a href="/tags/Flutter/" style="font-size: 16.67px;">Flutter</a> <a href="/tags/Git/" style="font-size: 12.22px;">Git</a> <a href="/tags/HTML/" style="font-size: 14.44px;">HTML</a> <a href="/tags/HTML5/" style="font-size: 12.22px;">HTML5</a> <a href="/tags/JSON/" style="font-size: 10px;">JSON</a> <a href="/tags/Java/" style="font-size: 11.11px;">Java</a> <a href="/tags/JavaScript/" style="font-size: 20px;">JavaScript</a> <a href="/tags/Javascript/" style="font-size: 10px;">Javascript</a> <a href="/tags/QT/" style="font-size: 12.22px;">QT</a> <a href="/tags/React/" style="font-size: 15.56px;">React</a> <a href="/tags/Sass/" style="font-size: 11.11px;">Sass</a> <a href="/tags/TheKnowledgeOf/" style="font-size: 11.11px;">TheKnowledgeOf</a> <a href="/tags/TypeScript/" style="font-size: 10px;">TypeScript</a> <a href="/tags/bootstrap/" style="font-size: 11.11px;">bootstrap</a> <a href="/tags/jQuery/" style="font-size: 13.33px;">jQuery</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/12/">December 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">November 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">October 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">September 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">July 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">June 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">May 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">April 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">March 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2019/12/29/Flutter-MaterialApp常用属性介绍/">Flutter-MaterialApp常用属性介绍</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-ListView/">Flutter-ListView</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-AppBar/">Flutter-AppBar</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-TabBar/">Flutter-TabBar</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-按钮/">Flutter-按钮</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2019 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>